package com.bwie.chenzihang.service;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.bwie.chenzihang.R;


public class Service2Activity extends AppCompatActivity implements View.OnClickListener {

    private Button btn1;
    private Button btn2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_service2);
        initView();
    }

    private void initView() {
        btn1 = (Button) findViewById(R.id.btn1);
        btn2 = (Button) findViewById(R.id.btn2);

        btn1.setOnClickListener(this);
        btn2.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent(this, Service2.class);
        switch (v.getId()) {
            case R.id.btn1:
                intent.putExtra("Toast", "Toast1");
                break;
            case R.id.btn2:
                intent.putExtra("Toast", "Toast2");
                break;
        }
        startService(intent);
    }
}